﻿namespace WLFramework.Web
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;

    public static class HttpResponseExtensions
    {
        public const string alert = "<script type=\"text/javascript\" language=\"javascript\">alert(\"{0}\");</script>";

        public static bool AlertErrorMessage(this HttpResponse response, string errorMessage)
        {
            Shield.AssertNotNull(ref response, "response");
            response.Write(string.Format(alert, errorMessage ?? string.Empty));
            return false;
        }

#if Net40

        public static bool AlertErrorMessage(this HttpResponseBase response, string errorMessage)
        {
            Shield.AssertNotNull(ref response, "response");
            response.Write(string.Format(alert, errorMessage ?? string.Empty));
            return false;
        }

#endif
    }
}
